/*
 * @Author: Wang Shuo wangshuo@sgsimulation.com
 * @Date: 2024-07-22 14:15:22
 * @LastEditors: Du Weixing duweixing@sgsimulation.com
 * @LastEditTime: 2024-12-07 13:55:06
 * @FilePath: \SGFEM\Solver\SectionCalculator\BeamSection\NumericalMethod\test\LSectionNumericalCalculatorTest.hpp
 * @Description: 
 * 
 * Copyright (c) 2024 by 神工仿真, All Rights Reserved. 
 */

#pragma once
#include "gtest/gtest.h"
#include "Utility/FileSystem/SGFileSystem.h"
#include "../Interface/BeamSectionNumericalCalculatorFactory.h"
#include "../LSectionNumericalCalculator.h"
#include "../SectionCalculator/writeVtk.h"

using SG::DataStructure::FEM::BeamSectionStandardTypes;
using SG::DataStructure::FEM::PBARLData;
using SG::FEMSolver::Element::BeamSectionNumericalCalculatorFactory;
using SG::FEMSolver::Element::LSectionNumericalCalculator;

// 将 BeamSectionNumericalCalculatorFactory 生成对象测试放置在具体截面属性计算中
TEST (BeamSectionNumericalCalculatorFactoryTest, LSectionCalculatorCreate)
{
    // Test data
    auto calculatorPtr = BeamSectionNumericalCalculatorFactory::Create (BeamSectionStandardTypes::BEAMSECTYPE_L);
    auto LCalculatorPtr = dynamic_cast<LSectionNumericalCalculator*> (calculatorPtr.get ());

    // Check
    ASSERT_TRUE (nullptr != LCalculatorPtr);
}

// L 截面网格划分测试
TEST (BeamSectionNumericalMeshTest, LSection)
{
    // Input data
    PBARLData section;
    section.SetBeamSectionStandardTypes (BeamSectionStandardTypes::BEAMSECTYPE_L);
    section.m_dimension = {8.0, 12.0, 4.0, 2.0};
    int refineLevel{2};

    // Test data
    Meshes meshes;
    LSectionNumericalCalculator LSecMesher;
    LSecMesher.Mesh (section, _OUT meshes, refineLevel);
    std::string filename = "LBeamSectionMesh";
    std::string discription = "L-Type Beam Section Mesh";
    SG::FEMSolver::Element::writeVtk (meshes, filename, discription);
    auto fileTest = SG::Utility::FileSystem::getFullPath (filename + ".vtk");

    // Target data
    auto fileTarget = SG::Utility::FileSystem::getTestDataPath ("SGFem/BeamSecPropCalculator/" + filename + "Target.vtk");

    // Check
    ASSERT_TRUE (SG::Utility::FileSystem::compareVTK (fileTarget, fileTest));
}